package user

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
	"ys-platform/models/sysuser"
	"ys-platform/services/user"
)

type userController struct {
}

func (u *userController) List(c *gin.Context) {
	// 将获取到的用户列表转换为JSON
	userList := user.UserService.GetUserList()
	if userList == nil {
		fmt.Println("获取数据为空")
	}
	c.JSONP(http.StatusOK, gin.H{"msg": userList})
	//c.JSON(http.StatusOK, userList)
}

func (u *userController) Add(c *gin.Context) {
	var sysUser sysuser.SysUser
	c.BindJSON(&sysUser)
	fmt.Println(sysUser)
	c.JSONP(200, gin.H{"msg": "保存成功"})
}

func (u *userController) Remove(c *gin.Context) {
	c.Query("userId")
	c.JSONP(200, gin.H{"msg": "删除成功"})
}

func (u *userController) Edit(c *gin.Context) {
	c.JSONP(200, gin.H{"msg": "修改成功"})
}

func (u *userController) BatchRemove(c *gin.Context) {
	c.JSONP(200, gin.H{"msg": "批量删除成功"})
}

var UserController = &userController{}
